<%@ include file="/common/taglibs.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Spring3-MiniWeb | Login</title>

<!-- CSS  -->
<link href="<c:url value="/resources/blueprint/screen.css" />"
	rel="stylesheet" type="text/css" />
<link href="<c:url value="/resources/style.css" />" rel="stylesheet"
	type="text/css" />

<!-- JS Library -->
<script type="text/javascript"
	src="<c:url value="/resources/jquery/1.5/jquery.js" />"></script>

<script type="text/javascript"
	src="<c:url value="/resources/validate/jquery.validate.js" />"></script>

<script type="text/javascript"
	src="<c:url value="/resources/validate/messages_cn.js" />"></script>

</head>
<body>
	<div class="container">
		<%@ include file="/common/header.jsp"%>
		<div id="content">
			<div class="span-24 last">
				<%
					if ("1".equals(request.getParameter("error"))) {
				%>
				<div class="error">用户名密码错误,请重试.</div>
				<%
					}
					if ("2".equals(request.getParameter("error"))) {
				%>
				<div class="error">验证码错误,请重试.</div>
				<%
					}
					if ("3".equals(request.getParameter("error"))) {
				%>
				<div class="error">此帐号已从别处登录.</div>
				<%
					}
				%>

				<form id="loginForm" style="margin-top: 1em;"
					action="<c:url value="/j_spring_security_check" />" method="post">
					<table class="noborder">
						<tr>
							<td><label for="username"> 用户名: </label>
							</td>
							<td><input type="text" id="j_username" name="j_username" class="required" />
							</td>
						</tr>

						<tr>
							<td><label for="password"> 密码: </label>
							</td>
							<td><input type="password" name="j_password"
								class="required" />
							</td>
						</tr>

						<tr>
							<td><label for="j_captcha">验证码:</label></td>
							<td><input type='text' name='j_captcha' size='5'
								class="required" /> <span style="margin-left: 25px"><a
									href="javascript:refreshCaptcha()">看不清楚换一张</a> </span> <img
								id="captchaImg" src="<c:url value="/jcaptcha.jpg"/>" />
							</td>
						</tr>

						<tr>
							<td><input type="checkbox"
								name="_spring_security_remember_me" /> <label>自动登录</label>
							</td>
							<td colspan="2"><input type="submit" class="button"
								value="登录" />
							</td>
						</tr>
					</table>
				</form>
				<div>
					(管理员<b>admin/admin</b>, 普通用户<b>user/user</b>)
				</div>
			</div>

		</div>
		<%@ include file="/common/footer.jsp"%>
	</div>

</body>
<script type="text/javascript">

	$(document).ready(function() {
		$("#j_username").focus();
		$("#loginForm").validate();
	});

	function refreshCaptcha() {
		$('#captchaImg').hide().attr(
				'src',
				'<c:url value="/jcaptcha.jpg"/>' + '?'
						+ Math.floor(Math.random() * 100)).fadeIn();
	}
</script>
</html>